function sub() {
    var aeskey = "",
        range = 16,
        arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
               'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
               'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
               'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
               'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
               'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
               'Y', 'Z'];
        for(var i=0; i<range; i++){
            pos = Math.round(Math.random() * (arr.length-1));
            aeskey += arr[pos];
        }

    var pwd = document.getElementById("userpwd").value;
    if(pwd == ""){
        alert("密码不能为空!");
    }else {
        var _word = CryptoJS.enc.Utf8.parse(pwd),
            _key = CryptoJS.enc.Utf8.parse(aeskey),
            _iv = CryptoJS.enc.Utf8.parse(aeskey);
        var encrypted1 = CryptoJS.AES.encrypt(_word, _key, {
            iv: _iv,
            mode: CryptoJS.mode.CBC,
            padding: CryptoJS.pad.Pkcs7
        });
        document.getElementById("userpwd").value = encrypted1.toString();

        var publickey;
        $.ajax({
            url: "/uc/pubkey",
            type: "post",
            async: false,
            success: function (data) {
                publickey = data;
            }
        });
        var encrypt = new JSEncrypt();
        encrypt.setPublicKey(publickey);
        var encrypted = encrypt.encrypt(aeskey);
        document.getElementById("key").value = encrypted;

        acountform.submit();
    }
}